﻿using System;
using System.Data;
using System.Web.UI.WebControls;

using BLL;

namespace EvaluationSystem
{
    public partial class FinanceQuery : System.Web.UI.Page
    {
        private EnterpriseUserBLL enterpriseUserBll = new EnterpriseUserBLL();
        private PaymentBLL paymentBll = new PaymentBLL();
        private string username = string.Empty;
        private string enterpriseId = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            ((SiteEnterpriseMaster)Master).InitMenu();
            ((SiteEnterpriseMaster)Master).li2.Attributes.Add("class", "hover ccc");
            ((SiteEnterpriseMaster)Master).b_hmenu1.Style.Add("display", "none");
            ((SiteEnterpriseMaster)Master).b_hmenu2.Style.Clear();
            ((SiteEnterpriseMaster)Master).b_hmenu3.Style.Add("display", "none");
            ((SiteEnterpriseMaster)Master).b_hmenu4.Style.Add("display", "none");
            ((SiteEnterpriseMaster)Master).s_menu2_1.Style.Add("COLOR", "#147ab8");
            ((SiteEnterpriseMaster)Master).s_menu2_1.Style.Add("TEXT-DECORATION", "none"); 

            /*判断是否是企业用户身份*/
            if (Session["username"] == null)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "PopupScript", "<script>alert('请先登录系统!');top.location.href='../Enterprise/EnterpriseLogin.aspx';</script>");
                return;
            }
            else
            {
                username = Session["username"].ToString();
                bind();
            }
        }

        private void bind()
        {
            enterpriseId = enterpriseUserBll.GetEnterpriseIdByUser(username);
            DataSet ds = paymentBll.GetPaymentByUID(enterpriseId);
            grVFinanceQuery.DataSource = ds.Tables[0].DefaultView;
            grVFinanceQuery.DataBind();

        }

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //e.Row.Attributes.Add("style", "height:30px");
        }

        protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {
            grVFinanceQuery.EditIndex = e.NewEditIndex;
            bind();
        }

        protected void GridView1_IndexChanging(object sender, GridViewPageEventArgs e)
        {
            grVFinanceQuery.PageIndex = e.NewPageIndex;
            bind();
        }
    }
}